$.fn.initLoad = function(obj, callback) {
    var that = this;
    var _callback = '';
    var _obj = '';
    if (typeof obj != 'object') {
        _callback = obj;
        _obj = false;
    } else {
        _callback = callback;
        _obj = obj;
    }
    var loadPro = function() {
        var html = '';
        $.ajax({
            type: 'post',
            url: url + 'address/getPca/info',
            data: {
                provinceParentId: 0
            },
            success: function(res) {
                res.datas.forEach(function(val, i) {
                    if (val.provinceId == "150000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >内蒙古</option>";
                    } else if (val.provinceId == "450000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >广西壮族</option>";
                    } else if (val.provinceId == "650000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >新疆维吾尔</option>";
                    } else if (val.provinceId == "640000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >宁夏回族</option>";
                    } else if (val.provinceId == "810000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >香港</option>";
                    } else if (val.provinceId == "820000") {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >澳门</option>";
                    } else {
                        html += "<option value='" + val.provinceId + "' " + (_obj && _obj.proId == val.provinceId && "selected") + " >" + val.provinceName + "</option>";
                    }
                })
                $('#one').html(html);

                _obj && loadCity(_obj.proId, true);

                $(that).find('#one').change(function() {
                    loadCity($(this).val());
                });
                $(that).find('#two').change(function() {
                    loadDistrict($(this).val());
                });
                $(that).find('#three').change(function() {
                    console.log()
                    _callback({
                        pro: [$('#one').val(), $("#one").find('option:selected').text()],
                        city: [$("#two").val(), $("#two").find('option:selected').text()],
                        area: [$("#three").val(), $("#three").find('option:selected').text()]
                    });
                });

            }
        })
    }

    var loadCity = function(val, load) {

        var html = '';
        $.ajax({
            type: 'post',
            url: url + 'address/getPca/info',
            data: {
                cityParentId: val
            },
            success: function(res) {
                res.datas.forEach(function(val, i) {
                    html += "<option value='" + val.cityId + "' " + (_obj && _obj.cityId == val.cityId && "selected") + " >" + val.cityName + "</option>";
                })
                $('#two').html(html);

                load ? loadDistrict(_obj.cityId) : loadDistrict($('#two').val());
            }
        })


    }

    var loadDistrict = function(val) {

        var html = '';
        $.ajax({
            type: 'post',
            url: url + 'address/getPca/info',
            data: {
                areaParentId: val
            },
            success: function(res) {
                res.datas.forEach(function(val, i) {
                    html += "<option value='" + val.areaId + "' " + (_obj && _obj.areaId == val.areaId && "selected") + " >" + val.areaName + "</option>";
                })
                $('#three').html(html);

                _callback({
                    pro: [$('#one').val(), $("#one").find('option:selected').text()],
                    city: [$("#two").val(), $("#two").find('option:selected').text()],
                    area: [$("#three").val(), $("#three").find('option:selected').text()]
                });
            }
        })
    }





    loadPro();

}